<template>
  <div v-if="currentFormData.length">
    <section v-for="(cItem,cIndex) in currentFormData" :key="cIndex" class="c-bg-white c-br16 c-ph24 c-mt30 c-mb30">
      <div class="c-pt24 c-pb16 c-flex-row c-aligni-center c-fs28">
        <div class="c-ww40 c-hh40 c-brp50 theme-bg c-flex-row c-flex-center">
          <i class="iconfont icon-user c-fc-white c-fs24"></i>
        </div>
        <span class="c-pl20 c-flex-grow1 c-w0 c-fw-b">报名人{{currentFormData.length ? cIndex * 1 + 1 : ''}}</span>
        <span v-if="cItem.fieldVal.length > 2" @click="clickShowAll(cIndex)" class="c-fc-gray c-fs22">{{cItem.isShowAll ? '收起':'展开'}}</span>
        <i v-if="cItem.fieldVal.length > 2" @click="clickShowAll(cIndex)"  :class="cItem.isShowAll ? 'c-rotate270':'c-rotate90'" class="iconfont c-fs20 c-fc-gray c-ml10">&#xe635;</i>
      </div>
      <div v-for="(item, index) in cItem.fieldVal" :key="index" v-show="item.enabled && (cItem.isShowAll || index < 2)" class="form-item c-fs24 c-pv28" :class="item.enabled && (cItem.isShowAll || index < 1)?'c-bd-b1':''">
        <!-- 1单文本 -->
        <div v-if="item.dataType == 1" class="c-flex-row c-aligni-center c-justify-sb">
          <div class=""><span class="c-mr6 c-fc-xlred c-fs28" v-if="item.isReq == 1">*</span>{{item.name}}</div>
          <div class="c-flex-row c-aligni-center c-w70">
            <!-- 为了解决ios上input输入文本超过可视范围，不能滑动，将input改为textarea -->
            <textarea cols="30" rows="1" wrap="off" style="overflow-y:hidden; resize:none; " maxlength="60" class="c-bd0 c-flex-grow1 c-w0  c-fs24 c-fc-xblack c-textAlign-r" :placeholder="item.placeholder ? item.placeholder : '请输入60个以内的字'" v-model="item['value' + cIndex]" />
          </div>
        </div>
        <!-- 2多文本 -->
        <div v-else-if="item.dataType == 2">
          <div class=""><span class="c-mr6 c-fc-xlred c-fs28" v-if="item.isReq == 1">*</span>{{item.name}}</div>
          <div class="c-w100">
            <textarea-com class="textareaClass c-pt28"  :placeholder="item.placeholder ? item.placeholder : '请输入200个以内的字'" :value="item['value' + cIndex]" @onChangeInput="item['value' + cIndex] = $event" maxLength="200" :showLength="true" @focus='inputFocus' @on-blur='inputBlur(item)'></textarea-com>
          </div>
        </div>
        <!-- 3数字 -->
        <div v-else-if="item.dataType == 3" class="c-flex-row c-aligni-center c-justify-sb">
          <div class=""><span class="c-mr6 c-fc-xlred c-fs28" v-if="item.isReq == 1">*</span>{{item.name}}</div>
          <div class="c-flex-row c-aligni-center c-w70">
            <input type="number" pattern="[0-9]*" @input="checkNumber(cIndex, index)" :placeholder="item.placeholder ? item.placeholder : '请输入数字'" v-model="item['value' + cIndex]" class="c-fc-xblack c-textAlign-r c-fs24 c-bd0 c-w100"/>
          </div>
        </div>
        <!-- 4日期 -->
        <div v-else-if="item.dataType == 4" class="c-flex-row c-aligni-center c-justify-sb">
          <div class=""><span class="c-mr6 c-fc-xlred c-fs28" v-if="item.isReq == 1">*</span>{{item.name}}</div>
          <div class="c-flex-row c-aligni-center c-w70">
            <group class="placeholder-gray c-w100 c-textAlign-r">
              <datetime title="" :themeColor="$getThemeColor()" v-model="item['value' + cIndex]" :start-date="startDate" :placeholder="item.placeholder ? item.placeholder : '请选择日期'"></datetime>
            </group>
          </div>
        </div>
        <!-- 5单选 -->
        <div v-else-if="item.dataType == 5">
          <div class=""><span class="c-mr6 c-fc-xlred c-fs28" v-if="item.isReq == 1">*</span>{{item.name}}</div>
          <div v-if="item.placeholder" class="c-fs20 c-fc-sgray c-ml10 c-mt4">{{item.placeholder}}</div>
          <div class="c-w100 c-pl20">
            <div v-for="(sitem, sindex) in item.options" :key="sindex" class="c-flex-row c-aligni-center c-pt28" @click="singleSelect(cIndex, index, sindex)">
              <i class="iconfont c-fs26 c-mr16" :class="(item['value' + cIndex] || item['value' + cIndex] == String(0)) && item['value' + cIndex] == sindex ? 'theme-fc' : 'c-fc-gray'">{{(item['value' + cIndex] || item['value' + cIndex] == String(0)) && item['value' + cIndex] == sindex ? '&#xe6b1;' : '&#xe6f7;'}}</i>
              <span>{{ sitem }}</span>
            </div>
          </div>
        </div>
        <!-- 6多选 -->
        <div v-else-if="item.dataType == 6">
          <div class=""><span class="c-mr6 c-fc-xlred c-fs28" v-if="item.isReq == 1">*</span>{{item.name}}</div>
          <div v-if="item.placeholder" class="c-fs20 c-fc-sgray c-ml10 c-mt4">{{item.placeholder}}</div>
          <div class="c-w100 c-pl20">
            <div v-for="(ditem, dindex) in item.options" :key="dindex" class="c-flex-row c-aligni-center c-w100 c-pt28" @click="custSelectMu(cIndex, index, dindex)">
              <i v-show="!(item['value' + cIndex] && item['value' + cIndex].includes(dindex))" class="iconfont c-fs30 c-lh42 c-fc-gray c-pr16">&#xe872;</i>
              <i v-show="item['value' + cIndex] && item['value' + cIndex].includes(dindex)" class="iconfont c-fs30 c-lh42 theme-fc c-pr16">&#xe871;</i>
              <span class="c-w100">{{ ditem }}</span>
            </div>
          </div>
        </div>
        <!-- 7省市区 -->
        <div v-else-if="item.dataType == 7">
          <div class="c-flex-row c-aligni-center c-justify-sb c-pb28">
            <div class=""><span class="c-mr6 c-fc-xlred c-fs28" v-if="item.isReq == 1">*</span>{{item.name}}</div>
            <div class="c-flex-row c-aligni-center c-w70" v-if="addressDataList">
              <group class="c-w100 c-textAlign-r c-fc-xblack addressSelected placeholder-gray">
                <x-address :themeColor="$getThemeColor()" @on-shadow-change="selectAddress" :title="''" v-model="item['value' + cIndex]" :list="addressDataList" :placeholder="item.placeholder ? item.placeholder : '请选择地址'" class="c-flex-grow1"></x-address>
              </group>
            </div>
          </div>
          <div class="c-flex-row c-aligni-center c-justify-sb c-pt28">
            <input type="text" maxlength="60" :placeholder="'请输入详细地址'" v-model="item.addressDetail" class="c-fc-xblack c-textAlign-r c-fs24 c-bd0 c-w100"/>
          </div>
        </div>
        <!-- 8性别 -->
        <div v-if="item.dataType == 8" class="c-flex-row c-aligni-center c-justify-sb">
          <div class=""><span class="c-mr6 c-fc-xlred c-fs28" v-if="item.isReq == 1">*</span>{{item.name}}</div>
          <div class="c-flex-row c-aligni-center">
            <group class="c-w100 c-textAlign-r placeholder-gray ">
              <popup-picker @on-change="onSexChange(cIndex, index)" :themeColor="$getThemeColor()" :data="sexData" class="c-flex-grow1" :title="''" v-model="item.value" :placeholder="item.placeholder ? item.placeholder : '请选择性别'"></popup-picker>
            </group>
            <div class="iconfont c-fs16 c-fc-gray c-ml10">&#xe60e;</div>
          </div>
        </div>
        <!-- 10手机号 -->
        <div v-if="item.dataType == 10" class="c-w100 c-flex-row c-justify-sb c-aligni-center">
          <div class=""><span class="c-mr6 c-fc-xlred c-fs28" v-if="item.isReq == 1">*</span>{{item.name}}</div>
          <div class=""><input type="tel" maxlength="11" v-model="item['value' + cIndex]" :placeholder="item.placeholder ? item.placeholder : `请输入${item.name}`" class="c-textAlign-r c-fs24 c-bd0"/></div>
        </div>
        <template v-if="item.dataType == 10 && item.isSystemField == 1 && isFromPromotedAccount && (promotedAccountStatus == 1 || promotedAccountStatus == 3) && (originMobile != Number(item['value' + cIndex]))">
          <div class="c-fs24 c-lh34 c-fc-xblack c-hh80 c-bd-b1 c-w100 c-flex-row c-justify-sb c-aligni-center">
            <div class="c-ww140 c-ws-n c-hh34 c-flex-shrink0"><span class="c-fc-xlred c-pr5">*</span>图片验证码</div>
            <input type="text" v-model="imgCode" maxlength="4" :placeholder="item.placeholder ? item.placeholder : '请输入图片验证码'" class="c-textAlign-r c-fs24 c-bd0 input c-hh34 c-ww220 c-ws-n" :class="imgCode == '' ? 'c-fc-sgray' : 'c-fc-xblack'" />
            <div class="c-ww166 c-hh64 c-flex-shrink0">
              <img :src="$addXossFilter(codeImgInfo.img)" alt="" class="c-w100 c-h" @click="getImgCode">
            </div>
          </div>
          <div class="c-fs24 c-lh34 c-fc-xblack c-hh80 c-bd-b1 c-w100 c-flex-row c-justify-sb c-aligni-center">
            <div class="c-ww120 c-ws-n"><span class="c-fc-xlred c-pr5">*</span>验证码</div>
            <input type="text" v-model="code" maxlength="4" @input="code=code.slice(0, 4)" :placeholder="item.placeholder ? item.placeholder : '请输入短信验证码'" class="c-textAlign-r c-fs24 c-bd0 input c-ww300" :class="code == '' ? 'c-fc-sgray' : 'c-fc-xblack'" />
            <div class="fc-f6 c-ph20">|</div>
            <div class="c-ws-n" @click="getYzcode" :class="yzText == '获取验证码' ? 'theme-fc c-ww120' : 'c-fc-gray c-ww180'">{{yzText}}</div>
          </div>
        </template>
        <!-- 11身份证号 -->
        <div class="c-flex-row c-justify-sb c-aligni-center" v-if="item.dataType == 11">
          <div class=""><span class="c-mr6 c-fc-xlred c-fs28" v-if="item.isReq == 1">*</span>{{item.name}}</div>
          <div class=""><input type="text" @input="checkIdCard(cIndex, index)" maxlength="18" v-model="item['value' + cIndex]" :placeholder="item.placeholder ? item.placeholder : `请输入${item.name}`" class="c-textAlign-r c-fs24 c-bd0"/></div>
        </div>
        <!-- 12上传图片 -->
        <div v-else-if="item.dataType == 12" class="">
          <div class=""><span class="c-mr6 c-fc-xlred c-fs28" v-if="item.isReq == 1">*</span>{{item.name}}</div>
          <div v-if="item.placeholder" class="c-fs20 c-fc-sgray c-ml10 c-mt4">{{item.placeholder}}</div>
          <!-- 上传的图片 -->
          <div class="c-pt30 c-flexw-wrap c-flex-row">
            <div v-for="(img,imgIndex) in item['value' + cIndex]" :key="imgIndex" class="c-ww170 c-hh170 c-mb20 c-flex-row c-flex-center c-p " :class="(imgIndex + 1) % 3 == 0 ? '':'c-mr20'">
              <div @click="delUploadImage(cIndex, index, imgIndex)" class="c-fc-gray del-img c-pz99">x</div>
              <img @click="clickPreviewImage(cIndex, index, img)" class="c-ww170 c-hh170" :src="img" alt="" />
            </div>
            <div v-if="item['value' + cIndex].length < 9" class="c-ww170 c-hh170 upload-bg c-flex-row c-flex-center c-p">
              <div class="c-ww170 c-hh170 c-flex-row c-flex-center" @click="clickAddPic(cIndex, index, '')">
                <i class="iconfont c-fs48 c-fc-gray">&#xe8ac;</i>
              </div>
              <input class="c-pa c-opacity0 c-p-t0 c-p-l0 c-ww170 c-hh170 c-fs10" v-if="!isWeiXin" ref="uploadImg" name="file" type="file" accept="image/*" @change="clickAddPic(cIndex, index, $event)" />
            </div>
          </div>
        </div>
        <div v-else-if="item.dataType == 13" class="c-flex-row c-aligni-center c-justify-sb">
          <div class=""><span class="c-mr6 c-fc-xlred c-fs28" v-if="item.isReq == 1">*</span>{{item.name}}</div>
          <div class="c-flex-row c-aligni-center c-flex-grow1 c-w0 c-pl20">
            <group class="c-w100 c-textAlign-r placeholder-gray">
              <popup-picker @on-change="onDownMenuChange(cIndex, index)" :themeColor="$getThemeColor()" :data="[item.options]" class="c-flex-grow1" :title="''" v-model="item.value" :placeholder="item.placeholder ? item.placeholder : '请选择'"></popup-picker>
            </group>
            <div class="iconfont c-fs16 c-fc-gray c-ml10">&#xe60e;</div>
          </div>
        </div>
      </div>
    </section>
  </div>
</template>
<script>
import { utilJs, wxUtilJs } from "@/utils/common";
import textareaCom from "@/components/templates/common/textareaCom.vue"
import { Datetime, PopupPicker, XAddress } from 'ckjrweb-mp-ui/src/components/index';
let inputScrollTop = 0;
let serverIdImgArr = []; //上传图片的serverID
let imgData = {};
export default {
  name: "ActivityEnrollForm",
  components: {
    textareaCom,
    Datetime,
    PopupPicker,
    XAddress
  },
  created() {
  },
  props: {
    currentFormData:{
      type: Array,
      default: () => []
    },
    selectedList:{
      type: Array,
      default: () => []
    },
    isCollectForm: {
      type: Number,
      default: 0
    },
    originMobile: {
      type: Number,
      default: 0
    }
  },
  data() {
    return {
      addressDataList: '',
      sexData: [["男", "女"]],
      accountTypeData: [["高级子店铺", "普通子店铺"]],
      isWeiXin: true,
      isShowNum: false, // 是否展示第几位
      isLoading: false,
      codeImgInfo: {},
      imgCode: '',
      code: '',
      yzText: "获取验证码",
      num: 60,
      startDate: "1920-01-01", //默认从2000年起
    };
  },
  computed: {
  },
  watch: {
  },
  mounted() {
    this.isWeiXin = utilJs.isWeiXin();
    this.isLoading = false;
    this.codeImgInfo = {};
    this.imgCode = '';
    this.code = '';
    this.yzText = "获取验证码";
    this.num = 60;
    this.getFormData()
    if (!utilJs.isWeiXin()) { //获取阿里云签名，除了微信浏览器以外
      utilJs.getAliSign(`${global.apiurl}imageSign`, res => {
        imgData = res;
      });
    }
  },
  methods: {
    mobileInput(e) {
      if (this.originMobile != Number(e.target.value)) {
        this.mobileChange = true;
      } else {
        this.mobileChange = false;
      }
    },
    cancelPopup() {
      this.$emit('cancel')
    },
    clickShowAll(cIndex) {
      this.currentFormData[cIndex].isShowAll = !this.currentFormData[cIndex].isShowAll;
    },
    checkNumber(cIndex, index) {
      let data = this.currentFormData[cIndex].fieldVal[index]['value' + cIndex]
      data = data.replace(/\D/g, '')
      this.currentFormData[cIndex].fieldVal[index]['value' + cIndex] = data
      this.$forceUpdate()
    },
    checkIdCard(cIndex, index) {
      let data = this.currentFormData[cIndex].fieldVal[index]['value' + cIndex]
      data = data.replace(/[\W]/g, '');
      this.currentFormData[cIndex].fieldVal[index]['value' + cIndex] = data;
      this.$forceUpdate()
    },
    onSexChange(cIndex, index) {
      this.currentFormData[cIndex].fieldVal[index]['value' + cIndex] = this.currentFormData[cIndex].fieldVal[index]['value']
    },
    onDownMenuChange(cIndex, index) {
       this.currentFormData[cIndex].fieldVal[index]['value' + cIndex] = this.currentFormData[cIndex].fieldVal[index]['value']
    },
    onAccountTypeChange(cIndex, index) {
      this.currentFormData[cIndex].fieldVal[index]['value' + cIndex] = this.currentFormData[cIndex].fieldVal[index]['value']
    },
    singleSelect(cIndex, index, sIndex) {
      this.currentFormData[cIndex].fieldVal[index]['value' + cIndex] = sIndex + ''
      this.$forceUpdate()
    },
    selectAddress(ids, names) {
      ids.forEach((id, index) => {
        this.selectedList[id] = names[index]
      })
    },
    submit() {
      let data = JSON.parse(JSON.stringify(this.currentFormData))
      for (let i = 0; i < data.length; i++) {
        for (let j = 0; j < data[i].fieldVal.length; j++) {
          if (data[i].fieldVal[j].isSystemField == 1 && data[i].fieldVal[j].dataType == 1 && !this.isFromPromotedAccount) {// 姓名
            data[i].name = data[i].fieldVal[j]['value' + i]
          }
          if (data[i].fieldVal[j].isSystemField == 1 && data[i].fieldVal[j].dataType == 10 && !this.isFromPromotedAccount) {// 手机号
            data[i].mobile = data[i].fieldVal[j]['value' + i]
          }
          if (data[i].fieldVal[j].dataType == 8) {
            data[i].fieldVal[j]['value' + i] = data[i].fieldVal[j]['value' + i][0]
          }
          if (!this.checkRules(i, data[i].fieldVal[j])) {
            return
          }
          if (data[i].fieldVal[j].dataType == 5 && data[i].fieldVal[j]['value' + i]) {
            data[i].fieldVal[j]['value' + i] = Number(data[i].fieldVal[j]['value' + i])
          }
          // 省市区+详细地址格式 {id: [], name: [], addressDetail: '详细地址'}
          if (data[i].fieldVal[j].dataType == 7 && data[i].fieldVal[j]['value' + i] && data[i].fieldVal[j]['value' + i].length > 0) {
            let nameList = []
            data[i].fieldVal[j]['value' + i].forEach((item, index) => {
              nameList.push(this.selectedList[item])
            })
            data[i].fieldVal[j]['value' + i] = {
              id: data[i].fieldVal[j]['value' + i],
              name: nameList,
              addressDetail: data[i].fieldVal[j].addressDetail
            };
            delete data[i].fieldVal[j].addressDetail
          }
          data[i].fieldVal[j]['value'] = data[i].fieldVal[j]['value' + i]
          delete data[i].fieldVal[j]['value' + i]
        }
      }
      this.$emit('submit', data)
    },
    checkYzm() {
      let mobileArr = this.currentFormData[0].fieldVal.filter(item => {
        return item.dataType == 10 && item.isSystemField == 1;
      })
      if (mobileArr.length == 0) {
        return true;
      }
      let mobile = mobileArr[0].value0;
      if (this.originMobile != mobile) {
        if (this.imgCode.length < 4) {
          this.$showCjToast({
            text: `请输入图片验证码`,
            type: "warn",
            time: 1000
          });
          return false
        }
        if (this.code.length < 4) {
          this.$showCjToast({
            text: `请输入验证码`,
            type: "warn",
            time: 1000
          });
          return false
        }
      }
      return true;
    },
    checkRules(i, data) {
      let personNum = this.currentFormData.length; // 需要填写几人的信息
      let value = data['value' + i];
      if ((data.dataType == 6 || data.dataType == 7 || data.dataType == 12) && data['value' + i]) {
        value = data['value' + i].join('')
      }
      // 必填 && 显示 （省市区还需要额外判断详细地址有没有填
      if (((data.dataType != 7 && !value) || (data.dataType == 7 && (!value || !data.addressDetail)) || (data.dataType == 999 && (!value || value.length == 0))) && data.isReq == 1 && data.enabled == 1) {
        this.$showCjToast({
          text: personNum > 1 ? `请完整填写第${i + 1}位信息` : `请完整填写信息`,
          type: "warn",
          time: 1000
        });
        return false
      }
      if ((data.dataType == 10 && !utilJs.isPhoneNumber(data['value' + i])) && data.isReq == 1 && data.enabled == 1) {
        this.$showCjToast({
          text: personNum > 1 ? `请填写第${i + 1}位正确的手机号` : `请填写正确的手机号`,
          type: "warn",
          time: 3000
        });
        return false;
      }
      return true;
    },
    custSelectMu(cIndex, index, data) {
      if (this.currentFormData[cIndex].fieldVal[index]['value' + cIndex].includes(data)) {
        let selectIndex = this.currentFormData[cIndex].fieldVal[index]['value' + cIndex].findIndex(i => i == data)
        this.currentFormData[cIndex].fieldVal[index]['value' + cIndex].splice(selectIndex, 1)
        this.$forceUpdate()
        return
      }
      this.currentFormData[cIndex].fieldVal[index]['value' + cIndex].push(data)
      this.$forceUpdate()
    },
    //点击选择图片
    clickAddPic(cIndex, index, event) {
      if (this.currentFormData[cIndex].fieldVal[index]['value' + cIndex].length > 9) {
        this.$showCjToast({
          text: "图片最多只能传9张",
          type: "warn",
          time: 1500
        });
        return;
      };
      if (this.isWeiXin) {
        wxUtilJs.chooseImage({
          count: 9, // 默认9
          sizeType: ["compressed"], // 可以指定是原图还是压缩图，默认二者都有
          sourceType: ["album", "camera"] // 可以指定来源是相册还是相机，默认二者都有
        }).then(localIds => {
          this.$loading.show({
            text: "上传中..."
          });
          serverIdImgArr = [];
          //获取剩余能传多少张图片，若已选的图片数量大于剩余数。则只传剩余数量的图片
          let residueLength = 9 - this.currentFormData[cIndex].fieldVal[index]['value' + cIndex].length;
          if (localIds.length > residueLength) {
            localIds.length = residueLength;
          }
          this.wxUploadImg(localIds, localIds.length - 1, index, cIndex);
        });
      } else {
        utilJs.imgUpload(event.target.files, imgData, 'form', res => {
          this.currentFormData[cIndex].fieldVal[index]['value' + cIndex].push(res)
          this.$forceUpdate()
        }, fRes => { });
      }
    },
    //上传图片到微信-----IOS不能一次性传多张，只好递归传
    wxUploadImg(localIds, localIdsLength, index, cIndex) {
      wxUtilJs
        .uploadImage({
          localId: localIds[localIdsLength]
        }, true)
        .then(res => {
          serverIdImgArr.push(res);
          if (localIdsLength > 0) {
            this.wxUploadImg(localIds, --localIdsLength, index, cIndex);
          } else {
            this.syncUploadPic(serverIdImgArr, index, cIndex, cIndex);
          }
        });
    },

    //上传图片到服务器
    syncUploadPic(serverIdArr, index, cIndex) {
      utilJs.postMethod(global.apiurl + "common/forms/wxUploadImg", {
        serverId: JSON.stringify(serverIdArr),
        mediaType: 2
      },
        res => {
          this.$loading.hide();
          for (let key of res) {
            if (this.currentFormData[cIndex].fieldVal[index]['value' + cIndex].length >= 9) {
              break;
            }
            this.currentFormData[cIndex].fieldVal[index]['value' + cIndex].push(key)
            this.$forceUpdate()
          }
        },
        failRes => {
          this.$loading.hide();
        }
      );
    },
    //删除上传的图片
    delUploadImage(cIndex, index, imgIndex) {
      this.currentFormData[cIndex].fieldVal[index]['value' + cIndex].splice(imgIndex, 1);
      this.$forceUpdate()
    },
    //点击图片放大预览
    clickPreviewImage(cIndex, index, imgUrl) {
      if (!imgUrl) {
        return;
      }
      let imgArr = [];
      for (let key of this.currentFormData[cIndex].fieldVal[index]['value' + cIndex]) {
        imgArr.push(key);
      }
      wxUtilJs.previewImage({
        current: imgUrl, // 当前显示图片的http链接
        urls: imgArr // 需要预览的图片http链接列表
      });
    },
    getFormData() {
      this.getAddress();
    },
    getImgCode() {
      if (this.isLoading == true) {
        return;
      }
      this.isLoading = true;
      utilJs.getMethod(`${global.apiurl}common/captcha`, res => {
        this.codeImgInfo = res;
        this.isLoading = false;
      }, failRes => {
        this.isLoading = false;
      });
    },
    getAddress() {
      utilJs.getMethod(`${global.apiurl}common/getAreaListForAgent`, res => {
        this.addressDataList = res.data;
      }, failRes => {
      });
    },
    getYzMethod: function () {
      this.isYz = false;
      this.num -= 1;
      this.yzText = this.num + "秒后重新获取";
      if (this.num == 0) {
        clearInterval(this.interval);
        this.yzText = "获取验证码";
        this.isYz = true;
        this.num = 60;
        this.isClick = false;
      }
    },
    getYzcode: function () {
      if (!this.isClick) {
        this.isClick = true;
        let mobileArr = this.currentFormData[0].fieldVal.filter(item => {
          return item.dataType == 10;
        })
        let mobile = mobileArr[0].value0;
        if (!!mobile) {
          if (this.imgCode == '') {
            this.$showCjToast({
              text: "图片验证码不能为空",
              type: "warn",
            });
            this.isClick = false;
          } else {
            let $this = this;
            $this.yzText = "发送中";
            utilJs.postMethod(global.apiurl + "members/sendCode", {
              mobile: mobile,
              captcha: this.imgCode,
              captchaKey: this.codeImgInfo.key,
            }, res => {
              if (res.errMsg) {
                $this.yzText = "获取验证码";
                $this.isClick = false;
                $this.$showCjToast({
                  text: res.errMsg,
                  type: "warn",
                });
              } else {
                $this.interval = setInterval($this.getYzMethod, 1000);
              }
            }, function () {
              clearInterval($this.interval);
              $this.yzText = "获取验证码";
              $this.isYz = true;
              $this.num = 60;
              $this.isClick = false;
            })
          }
        } else {
          this.$showCjToast({
            text: "手机号不能为空",
            type: "warn",
          });
          this.isClick = false;
        }
      }
    },
    //IOS微信6.7以上版本会导致输入法收起的时候，键盘没收起，需要手动滚下屏幕
    inputFocus() {
      if (navigator.userAgent.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/)) {
        inputScrollTop = document.documentElement.scrollTop || document.body.scrollTop;
      }
    },
    inputBlur() {
      if (navigator.userAgent.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/)) {
        setTimeout(() => {
          document.body.scrollTop = inputScrollTop - 1 || 0;
        });
      }
    },
  }
};
</script>

<style scoped>
.form-item:last-child{
  border: none;
}
.placeholder-gray >>> .vux-cell-placeholder {
  color: #cccccc;
}
.placeholder-gray >>> .vux-cell-value {
  color: #333333;
}
.textareaClass >>> textarea{
  resize: none;
  height: 3rem;
}
.upload-bg {
  background-color: #ecedee;
}
.del-img {
  position: absolute;
  top: -0.45rem;
  right: -0.45rem;
  cursor: pointer;
  font-size: 0.4rem;
  background-color: #ffa95d;
  border-radius: 50%;
  border: 2px solid #fff;
  width: 0.9rem;
  height: 0.9rem;
  display: flex;
  justify-content: center;
  align-items: center;
  color: #fff;
  z-index: 1;
}
</style>
